<template>
  <el-table :data="permission" border>
    <el-table-column prop="permissionName" show-overflow-tooltip label="权限名" align="center"></el-table-column>
    <el-table-column prop="url" show-overflow-tooltip label="权限路径" align="center"></el-table-column>
  </el-table>
</template>

<script>
// 请求
import { getRolePermissions } from '@/network/homeRequest.js';

export default {
  data() {
    return {
      permission: []
    }
  },
  props: {
    roleId: String
  },
  created() {
    this.getPermissions(this.roleId);
  },
  methods: {
    /**
     * 网络请求: 根据角色id获取权限
     */
    async getPermissions(rid) {
      const {meta, data} = await getRolePermissions(rid);
      // console.log(meta);
      
      if (meta.status != 200) {
        return this.$message(meta.msg);
      }
      // console.log(data);
      this.permission = data.permissions;
    }
  },
}
</script>